{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Selecting Subsets of Data "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "pd.set_option('max_columns', 4, 'max_rows', 10, 'max_colwidth', 12)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Introduction"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Selecting Series data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### How to do it..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Alabama A & M University                                       Normal\n",
       "University of Alabama at Birmingham                        Birmingham\n",
       "Amridge University                                         Montgomery\n",
       "University of Alabama in Huntsville                        Huntsville\n",
       "Alabama State University                                   Montgomery\n",
       "                                                             ...     \n",
       "SAE Institute of Technology  San Francisco                 Emeryville\n",
       "Rasmussen College - Overland Park                         Overland...\n",
       "National Personal Training Institute of Cleveland         Highland...\n",
       "Bay Area Medical Academy - San Jose Satellite Location       San Jose\n",
       "Excel Learning Center-San Antonio South                   San Antonio\n",
       "Name: CITY, Length: 7535, dtype: object"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college = pd.read_csv('data/college.csv', index_col='INSTNM')\n",
    "city = college['CITY']\n",
    "city"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Normal'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city['Alabama A & M University']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Normal'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city.loc['Alabama A & M University']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Normal'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city.iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Alabama A & M University        Normal\n",
       "Alabama State University    Montgomery\n",
       "Name: CITY, dtype: object"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city[['Alabama A & M University', 'Alabama State University']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Alabama A & M University        Normal\n",
       "Alabama State University    Montgomery\n",
       "Name: CITY, dtype: object"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city.loc[['Alabama A & M University', 'Alabama State University']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Alabama A & M University        Normal\n",
       "Alabama State University    Montgomery\n",
       "Name: CITY, dtype: object"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city.iloc[[0, 4]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Alabama A & M University                   Normal\n",
       "University of Alabama at Birmingham    Birmingham\n",
       "Amridge University                     Montgomery\n",
       "University of Alabama in Huntsville    Huntsville\n",
       "Alabama State University               Montgomery\n",
       "Name: CITY, dtype: object"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city['Alabama A & M University': 'Alabama State University']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Alabama A & M University                   Normal\n",
       "University of Alabama at Birmingham    Birmingham\n",
       "Amridge University                     Montgomery\n",
       "University of Alabama in Huntsville    Huntsville\n",
       "Alabama State University               Montgomery\n",
       "Name: CITY, dtype: object"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city[0:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Alabama A & M University                   Normal\n",
       "University of Alabama at Birmingham    Birmingham\n",
       "Amridge University                     Montgomery\n",
       "University of Alabama in Huntsville    Huntsville\n",
       "Alabama State University               Montgomery\n",
       "Name: CITY, dtype: object"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city.loc['Alabama A & M University': 'Alabama State University']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Alabama A & M University                   Normal\n",
       "University of Alabama at Birmingham    Birmingham\n",
       "Amridge University                     Montgomery\n",
       "University of Alabama in Huntsville    Huntsville\n",
       "Alabama State University               Montgomery\n",
       "Name: CITY, dtype: object"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city.iloc[0:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "University of Alabama at Birmingham    Birmingham\n",
       "Amridge University                     Montgomery\n",
       "Alabama State University               Montgomery\n",
       "Auburn University at Montgomery        Montgomery\n",
       "Birmingham Southern College            Birmingham\n",
       "                                          ...    \n",
       "Fortis Institute-Birmingham            Birmingham\n",
       "Hair Academy                           Montgomery\n",
       "Brown Mackie College-Birmingham        Birmingham\n",
       "Nunation School of Cosmetology         Birmingham\n",
       "Troy University-Montgomery Campus      Montgomery\n",
       "Name: CITY, Length: 26, dtype: object"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "alabama_mask = city.isin(['Birmingham', 'Montgomery'])\n",
    "city[alabama_mask]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### How it works..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5    10\n",
       "2    20\n",
       "3    35\n",
       "1    28\n",
       "dtype: int64"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = pd.Series([10, 20, 35, 28], index=[5,2,3,1])\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5    10\n",
       "2    20\n",
       "3    35\n",
       "1    28\n",
       "dtype: int64"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s[0:4]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s[5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "28"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s[1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### There's more..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Normal'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.loc['Alabama A & M University', 'CITY']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Normal'"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.iloc[0, 0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Alabama A & M University        Normal\n",
       "Alabama State University    Montgomery\n",
       "Name: CITY, dtype: object"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.loc[['Alabama A & M University', \n",
    "    'Alabama State University'], 'CITY']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Alabama A & M University        Normal\n",
       "Alabama State University    Montgomery\n",
       "Name: CITY, dtype: object"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.iloc[[0, 4], 0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Alabama A & M University                   Normal\n",
       "University of Alabama at Birmingham    Birmingham\n",
       "Amridge University                     Montgomery\n",
       "University of Alabama in Huntsville    Huntsville\n",
       "Alabama State University               Montgomery\n",
       "Name: CITY, dtype: object"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.loc['Alabama A & M University':\n",
    "    'Alabama State University', 'CITY']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Alabama A & M University                   Normal\n",
       "University of Alabama at Birmingham    Birmingham\n",
       "Amridge University                     Montgomery\n",
       "University of Alabama in Huntsville    Huntsville\n",
       "Alabama State University               Montgomery\n",
       "Name: CITY, dtype: object"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.iloc[0:5, 0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Series([], Name: CITY, dtype: object)"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city.loc['Reid State Technical College':\n",
    "         'Alabama State University']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Selecting DataFrame rows"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CITY</th>\n",
       "      <th>STABBR</th>\n",
       "      <th>...</th>\n",
       "      <th>MD_EARN_WNE_P10</th>\n",
       "      <th>GRAD_DEBT_MDN_SUPP</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Career Point College</th>\n",
       "      <td>San Antonio</td>\n",
       "      <td>TX</td>\n",
       "      <td>...</td>\n",
       "      <td>20700</td>\n",
       "      <td>14977</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ner Israel Rabbinical College</th>\n",
       "      <td>Baltimore</td>\n",
       "      <td>MD</td>\n",
       "      <td>...</td>\n",
       "      <td>PrivacyS...</td>\n",
       "      <td>PrivacyS...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Reflections Academy of Beauty</th>\n",
       "      <td>Decatur</td>\n",
       "      <td>IL</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>PrivacyS...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Capital Area Technical College</th>\n",
       "      <td>Baton Rouge</td>\n",
       "      <td>LA</td>\n",
       "      <td>...</td>\n",
       "      <td>26400</td>\n",
       "      <td>PrivacyS...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>West Virginia University Institute of Technology</th>\n",
       "      <td>Montgomery</td>\n",
       "      <td>WV</td>\n",
       "      <td>...</td>\n",
       "      <td>43400</td>\n",
       "      <td>23969</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 26 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                     CITY STABBR  ...  MD_EARN_WNE_P10  GRAD_DEBT_MDN_SUPP\n",
       "INSTNM                            ...                                     \n",
       "Career Po...  San Antonio     TX  ...        20700            14977       \n",
       "Ner Israe...    Baltimore     MD  ...  PrivacyS...      PrivacyS...       \n",
       "Reflectio...      Decatur     IL  ...          NaN      PrivacyS...       \n",
       "Capital A...  Baton Rouge     LA  ...        26400      PrivacyS...       \n",
       "West Virg...   Montgomery     WV  ...        43400            23969       \n",
       "\n",
       "[5 rows x 26 columns]"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college = pd.read_csv('data/college.csv', index_col='INSTNM')\n",
    "college.sample(5, random_state=42)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CITY                  Anchorage\n",
       "STABBR                       AK\n",
       "HBCU                          0\n",
       "MENONLY                       0\n",
       "WOMENONLY                     0\n",
       "                        ...    \n",
       "PCTPELL                  0.2385\n",
       "PCTFLOAN                 0.2647\n",
       "UG25ABV                  0.4386\n",
       "MD_EARN_WNE_P10           42500\n",
       "GRAD_DEBT_MDN_SUPP      19449.5\n",
       "Name: University of Alaska Anchorage, Length: 26, dtype: object"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.iloc[60]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CITY                  Anchorage\n",
       "STABBR                       AK\n",
       "HBCU                          0\n",
       "MENONLY                       0\n",
       "WOMENONLY                     0\n",
       "                        ...    \n",
       "PCTPELL                  0.2385\n",
       "PCTFLOAN                 0.2647\n",
       "UG25ABV                  0.4386\n",
       "MD_EARN_WNE_P10           42500\n",
       "GRAD_DEBT_MDN_SUPP      19449.5\n",
       "Name: University of Alaska Anchorage, Length: 26, dtype: object"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.loc['University of Alaska Anchorage']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CITY</th>\n",
       "      <th>STABBR</th>\n",
       "      <th>...</th>\n",
       "      <th>MD_EARN_WNE_P10</th>\n",
       "      <th>GRAD_DEBT_MDN_SUPP</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>University of Alaska Anchorage</th>\n",
       "      <td>Anchorage</td>\n",
       "      <td>AK</td>\n",
       "      <td>...</td>\n",
       "      <td>42500</td>\n",
       "      <td>19449.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>International Academy of Hair Design</th>\n",
       "      <td>Tempe</td>\n",
       "      <td>AZ</td>\n",
       "      <td>...</td>\n",
       "      <td>22200</td>\n",
       "      <td>10556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama in Huntsville</th>\n",
       "      <td>Huntsville</td>\n",
       "      <td>AL</td>\n",
       "      <td>...</td>\n",
       "      <td>45500</td>\n",
       "      <td>24097</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3 rows × 26 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                    CITY STABBR  ...  MD_EARN_WNE_P10  GRAD_DEBT_MDN_SUPP\n",
       "INSTNM                           ...                                     \n",
       "Universit...   Anchorage     AK  ...        42500          19449.5       \n",
       "Internati...       Tempe     AZ  ...        22200            10556       \n",
       "Universit...  Huntsville     AL  ...        45500            24097       \n",
       "\n",
       "[3 rows x 26 columns]"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.iloc[[60, 99, 3]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CITY</th>\n",
       "      <th>STABBR</th>\n",
       "      <th>...</th>\n",
       "      <th>MD_EARN_WNE_P10</th>\n",
       "      <th>GRAD_DEBT_MDN_SUPP</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>University of Alaska Anchorage</th>\n",
       "      <td>Anchorage</td>\n",
       "      <td>AK</td>\n",
       "      <td>...</td>\n",
       "      <td>42500</td>\n",
       "      <td>19449.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>International Academy of Hair Design</th>\n",
       "      <td>Tempe</td>\n",
       "      <td>AZ</td>\n",
       "      <td>...</td>\n",
       "      <td>22200</td>\n",
       "      <td>10556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama in Huntsville</th>\n",
       "      <td>Huntsville</td>\n",
       "      <td>AL</td>\n",
       "      <td>...</td>\n",
       "      <td>45500</td>\n",
       "      <td>24097</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3 rows × 26 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                    CITY STABBR  ...  MD_EARN_WNE_P10  GRAD_DEBT_MDN_SUPP\n",
       "INSTNM                           ...                                     \n",
       "Universit...   Anchorage     AK  ...        42500          19449.5       \n",
       "Internati...       Tempe     AZ  ...        22200            10556       \n",
       "Universit...  Huntsville     AL  ...        45500            24097       \n",
       "\n",
       "[3 rows x 26 columns]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "labels = ['University of Alaska Anchorage',\n",
    "          'International Academy of Hair Design',\n",
    "          'University of Alabama in Huntsville']\n",
    "college.loc[labels]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CITY</th>\n",
       "      <th>STABBR</th>\n",
       "      <th>...</th>\n",
       "      <th>MD_EARN_WNE_P10</th>\n",
       "      <th>GRAD_DEBT_MDN_SUPP</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>International Academy of Hair Design</th>\n",
       "      <td>Tempe</td>\n",
       "      <td>AZ</td>\n",
       "      <td>...</td>\n",
       "      <td>22200</td>\n",
       "      <td>10556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GateWay Community College</th>\n",
       "      <td>Phoenix</td>\n",
       "      <td>AZ</td>\n",
       "      <td>...</td>\n",
       "      <td>29800</td>\n",
       "      <td>7283</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mesa Community College</th>\n",
       "      <td>Mesa</td>\n",
       "      <td>AZ</td>\n",
       "      <td>...</td>\n",
       "      <td>35200</td>\n",
       "      <td>8000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3 rows × 26 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                 CITY STABBR  ...  MD_EARN_WNE_P10  GRAD_DEBT_MDN_SUPP\n",
       "INSTNM                        ...                                     \n",
       "Internati...    Tempe     AZ  ...        22200            10556       \n",
       "GateWay C...  Phoenix     AZ  ...        29800             7283       \n",
       "Mesa Comm...     Mesa     AZ  ...        35200             8000       \n",
       "\n",
       "[3 rows x 26 columns]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.iloc[99:102]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CITY</th>\n",
       "      <th>STABBR</th>\n",
       "      <th>...</th>\n",
       "      <th>MD_EARN_WNE_P10</th>\n",
       "      <th>GRAD_DEBT_MDN_SUPP</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>International Academy of Hair Design</th>\n",
       "      <td>Tempe</td>\n",
       "      <td>AZ</td>\n",
       "      <td>...</td>\n",
       "      <td>22200</td>\n",
       "      <td>10556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GateWay Community College</th>\n",
       "      <td>Phoenix</td>\n",
       "      <td>AZ</td>\n",
       "      <td>...</td>\n",
       "      <td>29800</td>\n",
       "      <td>7283</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mesa Community College</th>\n",
       "      <td>Mesa</td>\n",
       "      <td>AZ</td>\n",
       "      <td>...</td>\n",
       "      <td>35200</td>\n",
       "      <td>8000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3 rows × 26 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                 CITY STABBR  ...  MD_EARN_WNE_P10  GRAD_DEBT_MDN_SUPP\n",
       "INSTNM                        ...                                     \n",
       "Internati...    Tempe     AZ  ...        22200            10556       \n",
       "GateWay C...  Phoenix     AZ  ...        29800             7283       \n",
       "Mesa Comm...     Mesa     AZ  ...        35200             8000       \n",
       "\n",
       "[3 rows x 26 columns]"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "start = 'International Academy of Hair Design'\n",
    "stop = 'Mesa Community College'\n",
    "college.loc[start:stop]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### How it works..."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### There's more..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['University of Alaska Anchorage',\n",
       " 'International Academy of Hair Design',\n",
       " 'University of Alabama in Huntsville']"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.iloc[[60, 99, 3]].index.tolist()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Selecting DataFrame rows and columns simultaneously"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### How to do it..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CITY</th>\n",
       "      <th>STABBR</th>\n",
       "      <th>HBCU</th>\n",
       "      <th>MENONLY</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Alabama A &amp; M University</th>\n",
       "      <td>Normal</td>\n",
       "      <td>AL</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama at Birmingham</th>\n",
       "      <td>Birmingham</td>\n",
       "      <td>AL</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Amridge University</th>\n",
       "      <td>Montgomery</td>\n",
       "      <td>AL</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    CITY STABBR  HBCU  MENONLY\n",
       "INSTNM                                        \n",
       "Alabama A...      Normal     AL   1.0      0.0\n",
       "Universit...  Birmingham     AL   0.0      0.0\n",
       "Amridge U...  Montgomery     AL   0.0      0.0"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college = pd.read_csv('data/college.csv', index_col='INSTNM')\n",
    "college.iloc[:3, :4]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CITY</th>\n",
       "      <th>STABBR</th>\n",
       "      <th>HBCU</th>\n",
       "      <th>MENONLY</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Alabama A &amp; M University</th>\n",
       "      <td>Normal</td>\n",
       "      <td>AL</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama at Birmingham</th>\n",
       "      <td>Birmingham</td>\n",
       "      <td>AL</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Amridge University</th>\n",
       "      <td>Montgomery</td>\n",
       "      <td>AL</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    CITY STABBR  HBCU  MENONLY\n",
       "INSTNM                                        \n",
       "Alabama A...      Normal     AL   1.0      0.0\n",
       "Universit...  Birmingham     AL   0.0      0.0\n",
       "Amridge U...  Montgomery     AL   0.0      0.0"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.loc[:'Amridge University', :'MENONLY']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>WOMENONLY</th>\n",
       "      <th>SATVRMID</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Alabama A &amp; M University</th>\n",
       "      <td>0.0</td>\n",
       "      <td>424.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama at Birmingham</th>\n",
       "      <td>0.0</td>\n",
       "      <td>570.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Amridge University</th>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama in Huntsville</th>\n",
       "      <td>0.0</td>\n",
       "      <td>595.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Alabama State University</th>\n",
       "      <td>0.0</td>\n",
       "      <td>425.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              WOMENONLY  SATVRMID\n",
       "INSTNM                           \n",
       "Alabama A...        0.0     424.0\n",
       "Universit...        0.0     570.0\n",
       "Amridge U...        0.0       NaN\n",
       "Universit...        0.0     595.0\n",
       "Alabama S...        0.0     425.0"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.iloc[:, [4,6]].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>WOMENONLY</th>\n",
       "      <th>SATVRMID</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Alabama A &amp; M University</th>\n",
       "      <td>0.0</td>\n",
       "      <td>424.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama at Birmingham</th>\n",
       "      <td>0.0</td>\n",
       "      <td>570.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Amridge University</th>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama in Huntsville</th>\n",
       "      <td>0.0</td>\n",
       "      <td>595.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Alabama State University</th>\n",
       "      <td>0.0</td>\n",
       "      <td>425.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              WOMENONLY  SATVRMID\n",
       "INSTNM                           \n",
       "Alabama A...        0.0     424.0\n",
       "Universit...        0.0     570.0\n",
       "Amridge U...        0.0       NaN\n",
       "Universit...        0.0     595.0\n",
       "Alabama S...        0.0     425.0"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.loc[:, ['WOMENONLY', 'SATVRMID']].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SATMTMID</th>\n",
       "      <th>UGDS_NHPI</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>GateWay Community College</th>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>American Baptist Seminary of the West</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              SATMTMID  UGDS_NHPI\n",
       "INSTNM                           \n",
       "GateWay C...       NaN     0.0029\n",
       "American ...       NaN        NaN"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.iloc[[100, 200], [7, 15]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SATMTMID</th>\n",
       "      <th>UGDS_NHPI</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>GateWay Community College</th>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>American Baptist Seminary of the West</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              SATMTMID  UGDS_NHPI\n",
       "INSTNM                           \n",
       "GateWay C...       NaN     0.0029\n",
       "American ...       NaN        NaN"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rows = ['GateWay Community College',\n",
    "        'American Baptist Seminary of the West']\n",
    "columns = ['SATMTMID', 'UGDS_NHPI']\n",
    "college.loc[rows, columns]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.401"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.iloc[5, -4]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.401"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.loc['The University of Alabama', 'PCTFLOAN']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Empire Beauty School-Flagstaff     0\n",
       "Charles of Italy Beauty College    0\n",
       "Central Arizona College            0\n",
       "University of Arizona              0\n",
       "Arizona State University-Tempe     0\n",
       "Name: RELAFFIL, dtype: int64"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.iloc[90:80:-2, 5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "INSTNM\n",
       "Empire Beauty School-Flagstaff     0\n",
       "Charles of Italy Beauty College    0\n",
       "Central Arizona College            0\n",
       "University of Arizona              0\n",
       "Arizona State University-Tempe     0\n",
       "Name: RELAFFIL, dtype: int64"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "start = 'Empire Beauty School-Flagstaff'\n",
    "stop = 'Arizona State University-Tempe'\n",
    "college.loc[start:stop:-2, 'RELAFFIL']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### How it works..."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### There's more..."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Selecting data with both integers and labels"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### How to do it..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [],
   "source": [
    "college = pd.read_csv('data/college.csv', index_col='INSTNM')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(10, 19)"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "col_start = college.columns.get_loc('UGDS_WHITE')\n",
    "col_end = college.columns.get_loc('UGDS_UNKN') + 1\n",
    "col_start, col_end"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>UGDS_WHITE</th>\n",
       "      <th>UGDS_BLACK</th>\n",
       "      <th>...</th>\n",
       "      <th>UGDS_NRA</th>\n",
       "      <th>UGDS_UNKN</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Alabama A &amp; M University</th>\n",
       "      <td>0.0333</td>\n",
       "      <td>0.9353</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0059</td>\n",
       "      <td>0.0138</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama at Birmingham</th>\n",
       "      <td>0.5922</td>\n",
       "      <td>0.2600</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0179</td>\n",
       "      <td>0.0100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Amridge University</th>\n",
       "      <td>0.2990</td>\n",
       "      <td>0.4192</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.2715</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>University of Alabama in Huntsville</th>\n",
       "      <td>0.6988</td>\n",
       "      <td>0.1255</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0332</td>\n",
       "      <td>0.0350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Alabama State University</th>\n",
       "      <td>0.0158</td>\n",
       "      <td>0.9208</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0243</td>\n",
       "      <td>0.0137</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              UGDS_WHITE  UGDS_BLACK  ...  UGDS_NRA  UGDS_UNKN\n",
       "INSTNM                                ...                     \n",
       "Alabama A...      0.0333      0.9353  ...    0.0059     0.0138\n",
       "Universit...      0.5922      0.2600  ...    0.0179     0.0100\n",
       "Amridge U...      0.2990      0.4192  ...    0.0000     0.2715\n",
       "Universit...      0.6988      0.1255  ...    0.0332     0.0350\n",
       "Alabama S...      0.0158      0.9208  ...    0.0243     0.0137\n",
       "\n",
       "[5 rows x 9 columns]"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.iloc[:5, col_start:col_end]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### How it works..."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### There's more..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>UGDS_WHITE</th>\n",
       "      <th>UGDS_BLACK</th>\n",
       "      <th>...</th>\n",
       "      <th>UGDS_NRA</th>\n",
       "      <th>UGDS_UNKN</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Birmingham Southern College</th>\n",
       "      <td>0.7983</td>\n",
       "      <td>0.1102</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0051</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Chattahoochee Valley Community College</th>\n",
       "      <td>0.4661</td>\n",
       "      <td>0.4372</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Concordia College Alabama</th>\n",
       "      <td>0.0280</td>\n",
       "      <td>0.8758</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0466</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>South University-Montgomery</th>\n",
       "      <td>0.3046</td>\n",
       "      <td>0.6054</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0019</td>\n",
       "      <td>0.0326</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Enterprise State Community College</th>\n",
       "      <td>0.6408</td>\n",
       "      <td>0.2435</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0012</td>\n",
       "      <td>0.0069</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>James H Faulkner State Community College</th>\n",
       "      <td>0.6979</td>\n",
       "      <td>0.2259</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0007</td>\n",
       "      <td>0.0009</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>6 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              UGDS_WHITE  UGDS_BLACK  ...  UGDS_NRA  UGDS_UNKN\n",
       "INSTNM                                ...                     \n",
       "Birmingha...      0.7983      0.1102  ...    0.0000     0.0051\n",
       "Chattahoo...      0.4661      0.4372  ...    0.0000     0.0139\n",
       "Concordia...      0.0280      0.8758  ...    0.0466     0.0000\n",
       "South Uni...      0.3046      0.6054  ...    0.0019     0.0326\n",
       "Enterpris...      0.6408      0.2435  ...    0.0012     0.0069\n",
       "James H F...      0.6979      0.2259  ...    0.0007     0.0009\n",
       "\n",
       "[6 rows x 9 columns]"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "row_start = college.index[10]\n",
    "row_end = college.index[15]\n",
    "college.loc[row_start:row_end, 'UGDS_WHITE':'UGDS_UNKN']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/matt/.env/364/lib/python3.6/site-packages/ipykernel_launcher.py:1: FutureWarning: \n",
      ".ix is deprecated. Please use\n",
      ".loc for label based indexing or\n",
      ".iloc for positional indexing\n",
      "\n",
      "See the documentation here:\n",
      "http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#ix-indexer-is-deprecated\n",
      "  \"\"\"Entry point for launching an IPython kernel.\n",
      "/Users/matt/.env/364/lib/python3.6/site-packages/pandas/core/indexing.py:822: FutureWarning: \n",
      ".ix is deprecated. Please use\n",
      ".loc for label based indexing or\n",
      ".iloc for positional indexing\n",
      "\n",
      "See the documentation here:\n",
      "http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#ix-indexer-is-deprecated\n",
      "  retval = getattr(retval, self.name)._getitem_axis(key, axis=i)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>UGDS_WHITE</th>\n",
       "      <th>UGDS_BLACK</th>\n",
       "      <th>...</th>\n",
       "      <th>UGDS_NRA</th>\n",
       "      <th>UGDS_UNKN</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Birmingham Southern College</th>\n",
       "      <td>0.7983</td>\n",
       "      <td>0.1102</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0051</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Chattahoochee Valley Community College</th>\n",
       "      <td>0.4661</td>\n",
       "      <td>0.4372</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Concordia College Alabama</th>\n",
       "      <td>0.0280</td>\n",
       "      <td>0.8758</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0466</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>South University-Montgomery</th>\n",
       "      <td>0.3046</td>\n",
       "      <td>0.6054</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0019</td>\n",
       "      <td>0.0326</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Enterprise State Community College</th>\n",
       "      <td>0.6408</td>\n",
       "      <td>0.2435</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0012</td>\n",
       "      <td>0.0069</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>James H Faulkner State Community College</th>\n",
       "      <td>0.6979</td>\n",
       "      <td>0.2259</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0007</td>\n",
       "      <td>0.0009</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>6 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              UGDS_WHITE  UGDS_BLACK  ...  UGDS_NRA  UGDS_UNKN\n",
       "INSTNM                                ...                     \n",
       "Birmingha...      0.7983      0.1102  ...    0.0000     0.0051\n",
       "Chattahoo...      0.4661      0.4372  ...    0.0000     0.0139\n",
       "Concordia...      0.0280      0.8758  ...    0.0466     0.0000\n",
       "South Uni...      0.3046      0.6054  ...    0.0019     0.0326\n",
       "Enterpris...      0.6408      0.2435  ...    0.0012     0.0069\n",
       "James H F...      0.6979      0.2259  ...    0.0007     0.0009\n",
       "\n",
       "[6 rows x 9 columns]"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.ix[10:16, 'UGDS_WHITE':'UGDS_UNKN']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>UGDS_WHITE</th>\n",
       "      <th>UGDS_BLACK</th>\n",
       "      <th>...</th>\n",
       "      <th>UGDS_NRA</th>\n",
       "      <th>UGDS_UNKN</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Birmingham Southern College</th>\n",
       "      <td>0.7983</td>\n",
       "      <td>0.1102</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0051</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Chattahoochee Valley Community College</th>\n",
       "      <td>0.4661</td>\n",
       "      <td>0.4372</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Concordia College Alabama</th>\n",
       "      <td>0.0280</td>\n",
       "      <td>0.8758</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0466</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>South University-Montgomery</th>\n",
       "      <td>0.3046</td>\n",
       "      <td>0.6054</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0019</td>\n",
       "      <td>0.0326</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Enterprise State Community College</th>\n",
       "      <td>0.6408</td>\n",
       "      <td>0.2435</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0012</td>\n",
       "      <td>0.0069</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>James H Faulkner State Community College</th>\n",
       "      <td>0.6979</td>\n",
       "      <td>0.2259</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0007</td>\n",
       "      <td>0.0009</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>6 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              UGDS_WHITE  UGDS_BLACK  ...  UGDS_NRA  UGDS_UNKN\n",
       "INSTNM                                ...                     \n",
       "Birmingha...      0.7983      0.1102  ...    0.0000     0.0051\n",
       "Chattahoo...      0.4661      0.4372  ...    0.0000     0.0139\n",
       "Concordia...      0.0280      0.8758  ...    0.0466     0.0000\n",
       "South Uni...      0.3046      0.6054  ...    0.0019     0.0326\n",
       "Enterpris...      0.6408      0.2435  ...    0.0012     0.0069\n",
       "James H F...      0.6979      0.2259  ...    0.0007     0.0009\n",
       "\n",
       "[6 rows x 9 columns]"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.iloc[10:16].loc[:, 'UGDS_WHITE':'UGDS_UNKN']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Slicing lexicographically"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### How to do it..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [],
   "source": [
    "college = pd.read_csv('data/college.csv', index_col='INSTNM')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'Sp'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[0;32m~/.env/364/lib/python3.6/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mget_slice_bound\u001b[0;34m(self, label, side, kind)\u001b[0m\n\u001b[1;32m   5166\u001b[0m             \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 5167\u001b[0;31m                 \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_searchsorted_monotonic\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlabel\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mside\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   5168\u001b[0m             \u001b[0;32mexcept\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/.env/364/lib/python3.6/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36m_searchsorted_monotonic\u001b[0;34m(self, label, side)\u001b[0m\n\u001b[1;32m   5127\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 5128\u001b[0;31m         \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"index must be monotonic increasing or decreasing\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   5129\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mValueError\u001b[0m: index must be monotonic increasing or decreasing",
      "\nDuring handling of the above exception, another exception occurred:\n",
      "\u001b[0;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-50-aaf4176210a0>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mcollege\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Sp'\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m'Su'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;32m~/.env/364/lib/python3.6/site-packages/pandas/core/indexing.py\u001b[0m in \u001b[0;36m__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m   1422\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1423\u001b[0m             \u001b[0mmaybe_callable\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcom\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply_if_callable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mobj\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1424\u001b[0;31m             \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_getitem_axis\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmaybe_callable\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1425\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1426\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0m_is_scalar_access\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mTuple\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/.env/364/lib/python3.6/site-packages/pandas/core/indexing.py\u001b[0m in \u001b[0;36m_getitem_axis\u001b[0;34m(self, key, axis)\u001b[0m\n\u001b[1;32m   1795\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mslice\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1796\u001b[0m             \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_validate_key\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1797\u001b[0;31m             \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get_slice_axis\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1798\u001b[0m         \u001b[0;32melif\u001b[0m \u001b[0mcom\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_bool_indexer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1799\u001b[0m             \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_getbool_axis\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/.env/364/lib/python3.6/site-packages/pandas/core/indexing.py\u001b[0m in \u001b[0;36m_get_slice_axis\u001b[0;34m(self, slice_obj, axis)\u001b[0m\n\u001b[1;32m   1452\u001b[0m         \u001b[0mlabels\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mobj\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get_axis\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0maxis\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1453\u001b[0m         indexer = labels.slice_indexer(\n\u001b[0;32m-> 1454\u001b[0;31m             \u001b[0mslice_obj\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstart\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mslice_obj\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstop\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mslice_obj\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstep\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkind\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1455\u001b[0m         )\n\u001b[1;32m   1456\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/.env/364/lib/python3.6/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mslice_indexer\u001b[0;34m(self, start, end, step, kind)\u001b[0m\n\u001b[1;32m   5032\u001b[0m         \u001b[0mslice\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   5033\u001b[0m         \"\"\"\n\u001b[0;32m-> 5034\u001b[0;31m         \u001b[0mstart_slice\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mend_slice\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mslice_locs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstart\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mend\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstep\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mstep\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkind\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mkind\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   5035\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   5036\u001b[0m         \u001b[0;31m# return a slice\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/.env/364/lib/python3.6/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mslice_locs\u001b[0;34m(self, start, end, step, kind)\u001b[0m\n\u001b[1;32m   5246\u001b[0m         \u001b[0mstart_slice\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   5247\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0mstart\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 5248\u001b[0;31m             \u001b[0mstart_slice\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_slice_bound\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstart\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"left\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkind\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   5249\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0mstart_slice\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   5250\u001b[0m             \u001b[0mstart_slice\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/.env/364/lib/python3.6/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mget_slice_bound\u001b[0;34m(self, label, side, kind)\u001b[0m\n\u001b[1;32m   5168\u001b[0m             \u001b[0;32mexcept\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   5169\u001b[0m                 \u001b[0;31m# raise the original KeyError\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 5170\u001b[0;31m                 \u001b[0;32mraise\u001b[0m \u001b[0merr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   5171\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   5172\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mslc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mndarray\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/.env/364/lib/python3.6/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mget_slice_bound\u001b[0;34m(self, label, side, kind)\u001b[0m\n\u001b[1;32m   5162\u001b[0m         \u001b[0;31m# we need to look up the label\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   5163\u001b[0m         \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 5164\u001b[0;31m             \u001b[0mslc\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlabel\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   5165\u001b[0m         \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   5166\u001b[0m             \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/.env/364/lib/python3.6/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mget_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m   2897\u001b[0m                 \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   2898\u001b[0m             \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2899\u001b[0;31m                 \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_maybe_cast_indexer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   2900\u001b[0m         \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_indexer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmethod\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtolerance\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtolerance\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   2901\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0mindexer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mndim\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m1\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mindexer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msize\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n",
      "\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n",
      "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n",
      "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n",
      "\u001b[0;31mKeyError\u001b[0m: 'Sp'"
     ]
    }
   ],
   "source": [
    "college.loc['Sp':'Su']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [],
   "source": [
    "college = college.sort_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CITY</th>\n",
       "      <th>STABBR</th>\n",
       "      <th>...</th>\n",
       "      <th>MD_EARN_WNE_P10</th>\n",
       "      <th>GRAD_DEBT_MDN_SUPP</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Spa Tech Institute-Ipswich</th>\n",
       "      <td>Ipswich</td>\n",
       "      <td>MA</td>\n",
       "      <td>...</td>\n",
       "      <td>21500</td>\n",
       "      <td>6333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Spa Tech Institute-Plymouth</th>\n",
       "      <td>Plymouth</td>\n",
       "      <td>MA</td>\n",
       "      <td>...</td>\n",
       "      <td>21500</td>\n",
       "      <td>6333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Spa Tech Institute-Westboro</th>\n",
       "      <td>Westboro</td>\n",
       "      <td>MA</td>\n",
       "      <td>...</td>\n",
       "      <td>21500</td>\n",
       "      <td>6333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Spa Tech Institute-Westbrook</th>\n",
       "      <td>Westbrook</td>\n",
       "      <td>ME</td>\n",
       "      <td>...</td>\n",
       "      <td>21500</td>\n",
       "      <td>6333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Spalding University</th>\n",
       "      <td>Louisville</td>\n",
       "      <td>KY</td>\n",
       "      <td>...</td>\n",
       "      <td>41700</td>\n",
       "      <td>25000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Studio Academy of Beauty</th>\n",
       "      <td>Chandler</td>\n",
       "      <td>AZ</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Studio Jewelers</th>\n",
       "      <td>New York</td>\n",
       "      <td>NY</td>\n",
       "      <td>...</td>\n",
       "      <td>PrivacyS...</td>\n",
       "      <td>PrivacyS...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Stylemaster College of Hair Design</th>\n",
       "      <td>Longview</td>\n",
       "      <td>WA</td>\n",
       "      <td>...</td>\n",
       "      <td>17000</td>\n",
       "      <td>13320</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Styles and Profiles Beauty College</th>\n",
       "      <td>Selmer</td>\n",
       "      <td>TN</td>\n",
       "      <td>...</td>\n",
       "      <td>PrivacyS...</td>\n",
       "      <td>PrivacyS...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Styletrends Barber and Hairstyling Academy</th>\n",
       "      <td>Rock Hill</td>\n",
       "      <td>SC</td>\n",
       "      <td>...</td>\n",
       "      <td>PrivacyS...</td>\n",
       "      <td>9495.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>201 rows × 26 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                    CITY STABBR  ...  MD_EARN_WNE_P10  GRAD_DEBT_MDN_SUPP\n",
       "INSTNM                           ...                                     \n",
       "Spa Tech ...     Ipswich     MA  ...        21500             6333       \n",
       "Spa Tech ...    Plymouth     MA  ...        21500             6333       \n",
       "Spa Tech ...    Westboro     MA  ...        21500             6333       \n",
       "Spa Tech ...   Westbrook     ME  ...        21500             6333       \n",
       "Spalding ...  Louisville     KY  ...        41700            25000       \n",
       "...                  ...    ...  ...          ...              ...       \n",
       "Studio Ac...    Chandler     AZ  ...          NaN             6333       \n",
       "Studio Je...    New York     NY  ...  PrivacyS...      PrivacyS...       \n",
       "Stylemast...    Longview     WA  ...        17000            13320       \n",
       "Styles an...      Selmer     TN  ...  PrivacyS...      PrivacyS...       \n",
       "Styletren...   Rock Hill     SC  ...  PrivacyS...           9495.5       \n",
       "\n",
       "[201 rows x 26 columns]"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.loc['Sp':'Su']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### How it works..."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### There's more..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "lines_to_next_cell": 2
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college = college.sort_index(ascending=False)\n",
    "college.index.is_monotonic_decreasing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CITY</th>\n",
       "      <th>STABBR</th>\n",
       "      <th>...</th>\n",
       "      <th>MD_EARN_WNE_P10</th>\n",
       "      <th>GRAD_DEBT_MDN_SUPP</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>INSTNM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Dyersburg State Community College</th>\n",
       "      <td>Dyersburg</td>\n",
       "      <td>TN</td>\n",
       "      <td>...</td>\n",
       "      <td>26800</td>\n",
       "      <td>7475</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Dutchess Community College</th>\n",
       "      <td>Poughkee...</td>\n",
       "      <td>NY</td>\n",
       "      <td>...</td>\n",
       "      <td>32500</td>\n",
       "      <td>10250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Dutchess BOCES-Practical Nursing Program</th>\n",
       "      <td>Poughkee...</td>\n",
       "      <td>NY</td>\n",
       "      <td>...</td>\n",
       "      <td>36500</td>\n",
       "      <td>9500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Durham Technical Community College</th>\n",
       "      <td>Durham</td>\n",
       "      <td>NC</td>\n",
       "      <td>...</td>\n",
       "      <td>27200</td>\n",
       "      <td>11069.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Durham Beauty Academy</th>\n",
       "      <td>Durham</td>\n",
       "      <td>NC</td>\n",
       "      <td>...</td>\n",
       "      <td>PrivacyS...</td>\n",
       "      <td>15332</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Bacone College</th>\n",
       "      <td>Muskogee</td>\n",
       "      <td>OK</td>\n",
       "      <td>...</td>\n",
       "      <td>29700</td>\n",
       "      <td>26350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Babson College</th>\n",
       "      <td>Wellesley</td>\n",
       "      <td>MA</td>\n",
       "      <td>...</td>\n",
       "      <td>86700</td>\n",
       "      <td>27000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>BJ's Beauty &amp; Barber College</th>\n",
       "      <td>Auburn</td>\n",
       "      <td>WA</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>PrivacyS...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>BIR Training Center</th>\n",
       "      <td>Chicago</td>\n",
       "      <td>IL</td>\n",
       "      <td>...</td>\n",
       "      <td>PrivacyS...</td>\n",
       "      <td>15394</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B M Spurr School of Practical Nursing</th>\n",
       "      <td>Glen Dale</td>\n",
       "      <td>WV</td>\n",
       "      <td>...</td>\n",
       "      <td>PrivacyS...</td>\n",
       "      <td>PrivacyS...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1411 rows × 26 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                     CITY STABBR  ...  MD_EARN_WNE_P10  GRAD_DEBT_MDN_SUPP\n",
       "INSTNM                            ...                                     \n",
       "Dyersburg...    Dyersburg     TN  ...        26800             7475       \n",
       "Dutchess ...  Poughkee...     NY  ...        32500            10250       \n",
       "Dutchess ...  Poughkee...     NY  ...        36500             9500       \n",
       "Durham Te...       Durham     NC  ...        27200          11069.5       \n",
       "Durham Be...       Durham     NC  ...  PrivacyS...            15332       \n",
       "...                   ...    ...  ...          ...              ...       \n",
       "Bacone Co...     Muskogee     OK  ...        29700            26350       \n",
       "Babson Co...    Wellesley     MA  ...        86700            27000       \n",
       "BJ's Beau...       Auburn     WA  ...          NaN      PrivacyS...       \n",
       "BIR Train...      Chicago     IL  ...  PrivacyS...            15394       \n",
       "B M Spurr...    Glen Dale     WV  ...  PrivacyS...      PrivacyS...       \n",
       "\n",
       "[1411 rows x 26 columns]"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "college.loc['E':'B']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "jupytext": {
   "cell_metadata_filter": "-all",
   "main_language": "python",
   "notebook_metadata_filter": "-all"
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
